#!/bin/bash
# 作用：启/停ZooKeeper集群
if [ $# -ne 1 ]
then
	echo "请输入正确的指令start/stop/status" && exit
fi

case $1 in
"start")
	for host in hadoop102 hadoop103 hadoop104
	do
		echo "========== 启动$host的ZooKeeper =========="
		ssh $host "zkServer.sh start"
	done
;;
"stop")
	for host in hadoop102 hadoop103 hadoop104
	do
		echo "========== 停止$host的ZooKeeper =========="
		ssh $host "zkServer.sh stop"
	done
;;
"status")
	for host in hadoop102 hadoop103 hadoop104
	do
		echo "==========  查看$host的ZK状态   =========="
		ssh $host "zkServer.sh status"
	done
;;
*)
	echo "请输入正确的指令start/stop/status" && exit
;;
esac
